package com.boang.util;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;

/*
  @author: 13813
  @date: 2024/12/11 15:12
*/
public class StringToLocalDateTime {
    public static LocalDateTime parse(String dateTime) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        try {
            LocalDateTime localDateTime = LocalDateTime.parse(dateTime, formatter);
            return localDateTime;
        } catch (DateTimeParseException e) {
            System.err.println("Failed to parse date-time string: " + e.getMessage());
        }
        return null;
    }

    public static void main(String[] args) {
        StringToLocalDateTime.parse("2024-12-04 00:00:00");
    }
}
